﻿using furion.blog.Domain.MySQL;
using furion.blog.Domain.Query;
using furion.blog.Domain.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Domain.IRepositories
{
    /// <summary>
    /// 基础查询接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBaseRepository<T> where T : BaseModel
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        Task<bool> SaveModel(T model);

        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        Task<bool> SaveModels(List<T> models);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        Task<bool> UpdateModel(T model);

        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        Task<bool> UpdateModels(List<T> models);

        /// <summary>
        /// 通过id 获取
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> Get(long id);

        /// <summary>
        /// 查询第一个
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<T> First(BaseDetailQuery<T> query);

        /// <summary>
        /// 返回头几条数据
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<List<T>> Top(BaseDetailQuery<T> query);

        /// <summary>
        /// 查询所有
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<List<T>> All(BaseDetailQuery<T> query);

        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<PageVO> List(BasePageQuery query);

    }
}
